package com.aihna.mall.translation;

import cn.hutool.core.util.ObjectUtil;
import com.aihna.common.translation.annotation.TranslationType;
import com.aihna.common.translation.constant.TransConstant;
import com.aihna.common.translation.core.TranslationInterface;
import com.aihna.mall.domain.vo.StoreProductCateVo;
import com.aihna.mall.service.IStoreProductCateService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@AllArgsConstructor
@TranslationType(type = TransConstant.CATE_ID_TO_NAME)
public class ProductCateTranslationImpl implements TranslationInterface<String> {

    private final IStoreProductCateService storeProductCateService;


    @Override
    public String translation(Object key, String other) {
        if (key instanceof Long id){
            StoreProductCateVo storeProductCateVo = storeProductCateService.queryById(id);
            if(ObjectUtil.isNotNull(storeProductCateVo)) {
                return storeProductCateVo.getName();
            }
        }
        return null;
    }
}
